<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    /* const p1 = new Promise((resolve, reject) => {
           setTimeout(() => {
             // resolve();
             reject(
               "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
             );
           }, 2000);
         });
    */
    /* function push(location, onComplete, onAbort) {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          // resolve();
          reject(
            "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
          );
        }, 2000);
      })
        .then(onComplete)
        .catch(onAbort);
    }

    function myPush(a, onComplete = () => {}, onAbort = () => {}) {
      return push(a, onComplete, onAbort);
    }

    myPush("123"); */


    /* const p1 = new Promise((resolve, reject) => {
      setTimeout(() => {
        // resolve
        reject(
          "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
        )
      }, 2000);
    }) */



    /* function push(location, onComplete, onAbort) {
      //push方法返回一个失败的promise实例 如果没有处理失败promise的方法则错误信息会直接抛在浏览器
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          // resolve
          reject(
            "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
          )
        }, 2000);
      })
    }

    push() */


    function push(location, onComplete, onAbort) {
      //push方法返回一个失败的promise实例 如果没有处理失败promise的方法则错误信息会直接抛在浏览器
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          // resolve
          reject(
            "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
          )
        }, 2000);
      })
      .then(onComplete)
      .catch(onAbort)
    }

    function mayPush(location , onComplete = () => {} , onAbort = () => {}){
      return push(location , onComplete , onAbort)
    }

    mayPush("666")








  </script>
</body>

</html>